﻿using Sirenix.OdinInspector;
using Sirenix.OdinInspector.Editor;
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

// ReSharper disable once InconsistentNaming
public class GMWindow : OdinEditorWindow
{
    [MenuItem("Mini Tools/GM窗口", false, 100)]
    private static void Main()
    {
        var wind = GetWindow<GMWindow>();
        wind.Show();
    }

    [BoxGroup("GM指令")] [LabelText("GM指令")] public string mOdinGMCode = "";

    [BoxGroup("GM指令")] [LabelText("GM指令参数")]
    public string mOdinGMCodeParam = "";

    [BoxGroup("GM指令")]
    [Button("发送GM指令")]
    public void Send()
    {
        // if (!string.IsNullOrWhiteSpace(mOdinGMCode))
        // {
        //     SendGMCode(mOdinGMCode, mOdinGMCodeParam);
        // }
    }

    #region 快捷指令

    [FoldoutGroup("快捷命令")]
    [HorizontalGroup("快捷命令/快捷指令", LabelWidth = 40)]
    [VerticalGroup("快捷命令/快捷指令/Left")]
    [LabelText("发送道具(空格分开)"), LabelWidth(100)]
    [SuffixLabel("道具ID:道具数量")]
    public string mOdinGMItemIdStr = String.Empty;

    [VerticalGroup("快捷命令/快捷指令/Right")]
    [Button("发送", ButtonHeight = 16)]
    public void SendGmItem()
    {
        // GameFacade.Instance.StartCoroutine(SendGmItemCode());
    }

    // private IEnumerator SendGmItemCode()
    // {
    //     var arr = mOdinGMItemIdStr.Split(' ');
    //     ProtoGmRequest req = new ProtoGmRequest();
    //     foreach (var str in arr)
    //     {
    //         var itemData = str.ToIITuple();
    //         if (itemData.Item1 != 0)
    //         {
    //             req.Param = $"additem:{itemData.Item1.ToString()}:{itemData.Item2.ToString()}";
    //             TCPSender.ProtoGmRequest(req);
    //             yield return new WaitForSeconds(0.05f);
    //         }
    //         else
    //         {
    //             var itemArr = str.Split(':');
    //             if (itemArr.Length == 1)
    //             {
    //                 req.Param = $"additem:{itemArr[0]}";
    //                 TCPSender.ProtoGmRequest(req);
    //                 yield return new WaitForSeconds(0.05f);
    //             }
    //         }
    //     }
    //     Tips.ShowImageTips("GM指令完成");
    // }

    [VerticalGroup("快捷命令/快捷指令/Left")] [LabelText("召唤怪物"), LabelWidth(100)] [SuffixLabel("怪物ID")]
    public string mOdinGMMonsterIdStr = String.Empty;

    [VerticalGroup("快捷命令/快捷指令/Right")]
    [Button("发送", ButtonHeight = 16)]
    public void SendGmMonster()
    {
        // ProtoGmRequest req = new ProtoGmRequest();
        // req.Param = $"addmonster:{mOdinGMMonsterIdStr}";
        // TCPSender.ProtoGmRequest(req);
    }

    [VerticalGroup("快捷命令/快捷指令/Left")] [LabelText("跳转地图"), LabelWidth(100)] [SuffixLabel("地图ID")]
    public string mOdinGMMapIdStr = String.Empty;

    [VerticalGroup("快捷命令/快捷指令/Right")]
    [Button("发送", ButtonHeight = 16)]
    public void SendGmMap()
    {
        // ProtoGmRequest req = new ProtoGmRequest();
        // req.Param = $"gotomap:{mOdinGMMapIdStr}";
        // TCPSender.ProtoGmRequest(req);
    }

    [VerticalGroup("快捷命令/快捷指令/Left")] [LabelText("英魂添加心情"), LabelWidth(100)] [SuffixLabel("心情值")]
    public string mOdinGMMoodStr = String.Empty;

    [VerticalGroup("快捷命令/快捷指令/Right")]
    [Button("发送", ButtonHeight = 16)]
    public void SendGmMood()
    {
        // ProtoGmRequest req = new ProtoGmRequest();
        // req.Param = $"allheroaddmood:{mOdinGMMoodStr}";
        // TCPSender.ProtoGmRequest(req);
    }

    [VerticalGroup("快捷命令/快捷指令/Left")] [LabelText("强化装备至满级"), LabelWidth(100)] [SuffixLabel("装备ID")]
    public string mOdinGMEquipStr = String.Empty;

    [VerticalGroup("快捷命令/快捷指令/Right")]
    [Button("发送", ButtonHeight = 16)]
    public void SendGmEquip()
    {
        // IntensifyItem(mOdinGMEquipStr);
    }

    [VerticalGroup("快捷命令/快捷指令/Left")] [LabelText("添加经验值"), LabelWidth(100)] [SuffixLabel("经验值")]
    public string mOdinGMExpStr = String.Empty;

    [VerticalGroup("快捷命令/快捷指令/Right")]
    [Button("发送", ButtonHeight = 16)]
    public void SendGmAddExp()
    {
        // ProtoGmRequest req = new ProtoGmRequest();
        // req.Param = $"addexp:{mOdinGMExpStr}";
        // TCPSender.ProtoGmRequest(req);
    }

    [VerticalGroup("快捷命令/快捷指令/Left")] [LabelText("添加极位经验值"), LabelWidth(100)] [SuffixLabel("经验值")]
    public string mOdinGMSuperExpStr = String.Empty;

    [VerticalGroup("快捷命令/快捷指令/Right")]
    [Button("发送", ButtonHeight = 16)]
    public void SendGmAddApExp()
    {
        //ProtoGmRequest req = new ProtoGmRequest();
        //req.Param = $"apexp:{mOdinGMSuperExpStr}";
        //TCPSender.ProtoGmRequest(req);
    }

    [VerticalGroup("快捷命令/快捷指令/Left")] [LabelText("完成任务(空格分开)"), LabelWidth(100)] [SuffixLabel("任务id")]
    public string mOdinGMTaskStr = String.Empty;

    [VerticalGroup("快捷命令/快捷指令/Right")]
    [Button("发送", ButtonHeight = 16)]
    public void SendGmTasked()
    {
        // GameFacade.Instance.StartCoroutine(SendGmTaskedCode());
    }
    // private IEnumerator SendGmTaskedCode()
    // {
    //     var arr = mOdinGMTaskStr.Split(' ');
    //     ProtoGmRequest req = new ProtoGmRequest();
    //     foreach (var str in arr)
    //     {
    //         if (int.TryParse(str, out int taskId))
    //         {
    //             var quest = CSVQuest.Get(taskId);
    //             if (null == quest)
    //             {
    //                 continue;
    //             }
    //             var delTiemStr = quest.sDelTaskItem;
    //             if (!string.IsNullOrEmpty(delTiemStr))
    //             {
    //                 var DelTaskItems = delTiemStr.Split(';');
    //                 for (int i = 0; i < DelTaskItems.Length; i++)
    //                 {
    //                     var itemData = DelTaskItems[i].ToIITuple();
    //                     req.Param = $"additem:{itemData.Item1.ToString()}:{itemData.Item2.ToString()}";
    //                     TCPSender.ProtoGmRequest(req);
    //                 }
    //                 yield return new WaitForSeconds(0.05f);
    //             }
    //             req.Param = $"tasked:{str}";
    //             TCPSender.ProtoGmRequest(req);
    //             yield return new WaitForSeconds(0.05f);
    //         }
    //     }
    //     Tips.ShowImageTips("GM指令完成");
    // }

    public enum EgmBoxType
    {
        None = 0,
        [LabelText("道具背包")] Pocket = 1, //人物背包
        [LabelText("素材背包")] TemporaryBag = 14, //副本临时背包

        // [LabelText("人物身上背包")]
        // PlayerEuipBag = 2,      //人物身上背包
        [LabelText("副本背包")] PetBag = 3, //副本背包
        [LabelText("道具仓库")] MainCityBag = 4, //主程仓库
        [LabelText("素材仓库")] Mat = 8, //素材仓库
        [LabelText("装备仓库")] DeopEuipBag = 6, //装备仓库
        // [LabelText("家园格子背包")]
        // BuildProductBag = 5,    //家园格子背包
        // [LabelText("腰包")]
        // YaoBao = 7,            //快捷背包，用于战斗使用道具
        // [LabelText("额外背包")]
        // ExtraBag = 13,      //额外背包
        // [LabelText("英魂背包")]
        // HeroBag = 16,      //英魂背包
    }

    [VerticalGroup("快捷命令/快捷指令/Left")] [LabelText("清空指定背包道具"), LabelWidth(100)] [SuffixLabel("任务id")]
    public EgmBoxType eBoxType = EgmBoxType.None;

    [VerticalGroup("快捷命令/快捷指令/Right")]
    [Button("发送", ButtonHeight = 16)]
    public void SendGmClearBag()
    {
        // GameFacade.Instance.StartCoroutine(SendGmClearBagCode());
    }

    // private IEnumerator SendGmClearBagCode()
    // {
    //     var inventory = NetData.Instance.Find<NetInventory>();
    //     var items = inventory.Find((InventoryBoxType)eBoxType).GetAllNetItem();
    //     foreach (var item in items)
    //     {
    //         TCPSender.ProtoDelItemRequest(item.ItemSrl, (int)eBoxType);
    //         yield return new WaitForSeconds(0.05f);
    //     }
    //     Tips.ShowImageTips("GM指令完成");
    // }

    [FoldoutGroup("快捷命令")]
    [Button("获取测试武器和装备", ButtonSizes.Medium)]
    public void SendGetTestEquip()
    {
        // ProtoGmRequest req = new ProtoGmRequest();
        // req.Param = "additem:1097";
        // TCPSender.ProtoGmRequest(req);
        // req = new ProtoGmRequest();
        // req.Param = "additem:100";
        // TCPSender.ProtoGmRequest(req);
        // req = new ProtoGmRequest();
        // req.Param = "additem:110";
        // TCPSender.ProtoGmRequest(req);
        // req = new ProtoGmRequest();
        // req.Param = "additem:2100";
        // TCPSender.ProtoGmRequest(req);
    }

    [FoldoutGroup("快捷命令")]
    [Button("刷新生态任务", ButtonSizes.Medium)]
    public void SendFlushTask()
    {
        // ProtoGmRequest req = new ProtoGmRequest();
        // req.Param = "resetrewardtask";
        // TCPSender.ProtoGmRequest(req);
    }

    [FoldoutGroup("快捷命令")]
    [Button("角色页面功能全解锁", ButtonSizes.Medium)]
    public void SendAuf()
    {
        // Auf();
    }

    [FoldoutGroup("快捷命令")]
    [Button("解锁全部任务", ButtonSizes.Medium)]
    public void SendTaskDall()
    {
        // ProtoGmRequest req = new ProtoGmRequest();
        // req.Param = "taskedall";
        // TCPSender.ProtoGmRequest(req);
    }

    [FoldoutGroup("快捷命令")]
    [Button("解锁英魂", ButtonSizes.Medium)]
    public void SendHero()
    {
        // ProtoGmRequest req = new ProtoGmRequest();
        // req.Param = "drop:300";
        // TCPSender.ProtoGmRequest(req);
        // req = new ProtoGmRequest();
        // req.Param = string.Format("drop:301");
        // TCPSender.ProtoGmRequest(req);
        // ProtoGmRequest itemReq = new ProtoGmRequest();
        // itemReq.Param = "additem:41160";
        // TCPSender.ProtoGmRequest(itemReq);
        // itemReq.Param = "additem:41161:100";
        // TCPSender.ProtoGmRequest(itemReq);
        // itemReq.Param = "additem:41020";
        // TCPSender.ProtoGmRequest(itemReq);
        // itemReq.Param = "additem:41021:100";
        // TCPSender.ProtoGmRequest(itemReq);
    }

    [FoldoutGroup("快捷命令")]
    [Button("清除buff(睡觉,泡澡,猫饭)", ButtonSizes.Medium)]
    public void ClearBuff()
    {
        // ProtoGmRequest req = new ProtoGmRequest();
        // req.Param = "clearbuff";
        // TCPSender.ProtoGmRequest(req);
    }

    [FoldoutGroup("快捷命令")]
    [Button("极位boss活动添加行动点", ButtonSizes.Medium)]
    public void AddExtremeBossActPoint()
    {
        // ProtoGmRequest req = new ProtoGmRequest();
        // req.Param = "apexpoint";
        // TCPSender.ProtoGmRequest(req);
    }

    [FoldoutGroup("快捷命令")]
    [Button("击杀当前场景boss", ButtonSizes.Medium)]
    public void KillCurrSceneBoss()
    {
        // ProtoGmRequest req = new ProtoGmRequest();
        // req.Param = "scenekillmonster";
        // TCPSender.ProtoGmRequest(req);
    }

    [FoldoutGroup("快捷命令")]
    [Button("极位挑战快速获得所有碎片", ButtonSizes.Medium)]
    public void GetAllExtremeBossPart()
    {
        // GameFacade.Instance.StartCoroutine(StartGetAllExtremeBossPart());
    }

    // private WaitForSeconds waitForSeconds = new WaitForSeconds(0.1f);
    // private IEnumerator StartGetAllExtremeBossPart()
    // {
    //     var data = NetData.Instance.Find<NetLimitActivitysData>();
    //     if (data == null)
    //     {
    //         yield break;
    //     }

    //     if (data.ExtremeBossMapIdx <= 0)
    //     {
    //         yield break;
    //     }

    //     if (data.ExtremeBossMapPartCount != 0)
    //     {
    //         var b = true;
    //         while (b)
    //         {
    //             b = false;
    //             var values = data.DicExtremeBossMapInfo.Values;
    //             foreach (var info in values)
    //             {
    //                 var csvMapItem = CSVExtremeBossMapInfo.Get(info.Type);
    //                 if (null == csvMapItem || csvMapItem.MapType != CSVExtremeBossMapInfo.MapItemType.MapPart ||
    //                     info.State != 0)
    //                 {
    //                     continue;
    //                 }

    //                 b = true;
    //                 if (data.ExtremeBossActPoint <= 0)
    //                 {
    //                     AddExtremeBossActPoint();
    //                     yield return waitForSeconds;
    //                     break;
    //                 }

    //                 TCPSender.C2SApexGridMoveReq(info.Pos);
    //                 yield return waitForSeconds;
    //                 break;
    //             }
    //         }
    //     }

    //     TCPSender.C2SEnterNextTierReq();
    //     yield return new WaitForSeconds(0.2f);

    //     yield return GameFacade.Instance.StartCoroutine(StartGetAllExtremeBossPart());
    // }

    #endregion

    #region 表格查找

    [FoldoutGroup("表格查找")] [FoldoutGroup("表格查找/查找道具")] [HorizontalGroup("表格查找/查找道具/1")] [LabelText("查找道具 名称包含")]
    public string mOdinSearchItemStr = String.Empty;

    [HorizontalGroup("表格查找/查找道具/1")]
    [Button("查找道具")]
    public void SearchItem()
    {
        // itemTableList.Clear();
        // if (string.IsNullOrEmpty(mOdinSearchItemStr))
        // {
        //     mShowSearchItem = false;
        //     return;
        // }
        // mShowSearchItem = true;
        // var items = CSVItemAll.GetAllLst();
        // foreach (var item in items)
        // {
        //     if (item.sItemName.Contains(mOdinSearchItemStr))
        //     {
        //         itemTableList.Add(new GMItemTable(item));
        //     }
        // }
    }
    //private bool mShowSearchItem = false;

    [FoldoutGroup("表格查找/查找道具")] [ShowIf("mShowSearchItem", true)] [TableList(MaxScrollViewHeight = 500)]
    public List<GmItemTable> itemTableList = new();

    [Serializable]
    public class GmItemTable
    {
        [TableColumnWidth(60, false)]
        [VerticalGroup("道具图标")]
        [PreviewField(Alignment = ObjectFieldAlignment.Center)]
        [HideLabel]
        public Texture Icon;

        [VerticalGroup("道具属性"), LabelWidth(50)] [LabelText("道具ID")]
        public int ItemId = 0;

        [VerticalGroup("道具属性"), LabelWidth(50)] [LabelText("道具名称")]
        public string ItemName = string.Empty;

        [TableColumnWidth(70, false)]
        [Button("获取道具", ButtonSizes.Medium)]
        [VerticalGroup("功能")]
        public void GetItem()
        {
            // ProtoGmRequest req = new ProtoGmRequest();
            // req.Param = $"additem:{ItemId.ToString()}";
            // TCPSender.ProtoGmRequest(req);
        }

        //public GMItemTable(CSVItemAll itemTable)
        //{
        //    ItemId = itemTable.iItemID;
        //    ItemName = itemTable.sItemName;
        //    Icon = AssetDatabase.LoadAssetAtPath<Texture>($"Assets/Project/Res/{itemTable.sIconPath}");
        //}
    }

    [FoldoutGroup("表格查找/查找怪物")] [HorizontalGroup("表格查找/查找怪物/1")] [LabelText("查找怪物 名称包含")]
    public string mOdinSearchMonsterStr = String.Empty;

    [HorizontalGroup("表格查找/查找怪物/1")]
    [Button("查找怪物")]
    public void SearchMonster()
    {
        // monsterTableList.Clear();
        // if (string.IsNullOrEmpty(mOdinSearchMonsterStr))
        // {
        //     mShowSearchMonster = false;
        //     return;
        // }
        // mShowSearchMonster = true;
        // var monsters = CSVMonsterGenerator.GetAllLst();
        // foreach (var monster in monsters)
        // {
        //     if (monster.sName.Contains(mOdinSearchMonsterStr))
        //     {
        //         monsterTableList.Add(new GMMonsterTable(monster));
        //     }
        // }
    }
    //private bool mShowSearchMonster = false;

    [FoldoutGroup("表格查找/查找怪物")] [ShowIf("mShowSearchMonster", true)] [TableList(MaxScrollViewHeight = 500)]
    public List<GmMonsterTable> monsterTableList = new();

    [Serializable]
    public class GmMonsterTable
    {
        [VerticalGroup("怪物ID"), LabelWidth(50)] [HideLabel]
        public int MonsterId = 0;

        [VerticalGroup("怪物名称"), LabelWidth(50)] [HideLabel]
        public string MonsterName = string.Empty;

        [TableColumnWidth(60)] [VerticalGroup("怪物等级")] [HideLabel]
        public int MonsterLevel;

        [TableColumnWidth(70, false)]
        [Button("召唤怪物", ButtonSizes.Medium)]
        [VerticalGroup("功能")]
        public void AddMonster()
        {
            //ProtoGmRequest req = new ProtoGmRequest();
            //req.Param = $"addmonster:{MonsterId.ToString()}";
            //TCPSender.ProtoGmRequest(req);
        }

        //public GMMonsterTable(CSVMonsterGenerator monsterTable)
        //{
        //    MonsterId = monsterTable.iID;
        //    MonsterName = monsterTable.sName;
        //    MonsterLevel = monsterTable.ilevel;
        //}
    }

    [FoldoutGroup("表格查找/查找英魂(填 1 全查找)")] [HorizontalGroup("表格查找/查找英魂(填 1 全查找)/1")] [LabelText("查找英魂 名称包含")]
    public string mOdinSearchHeroStr = String.Empty;

    [HorizontalGroup("表格查找/查找英魂(填 1 全查找)/1")]
    [Button("查找英魂")]
    public void SearchHero()
    {
        // heroTableList.Clear();
        // if (string.IsNullOrEmpty(mOdinSearchHeroStr))
        // {
        //     mShowSearchHero = false;
        //     return;
        // }
        // mShowSearchHero = true;
        // var heroInfos = CSVHeroInfo.GetAllLst();
        // foreach (var heroInfo in heroInfos)
        // {
        //     if (heroInfo.sHeroName.Contains(mOdinSearchHeroStr) || mOdinSearchHeroStr.Equals("1"))
        //     {
        //         heroTableList.Add(new GMHeroTable(heroInfo));
        //     }
        // }
    }
    //private bool mShowSearchHero = false;

    [FoldoutGroup("表格查找/查找英魂(填 1 全查找)")] [ShowIf("mShowSearchHero", true)] [TableList(MaxScrollViewHeight = 500)]
    public List<GmHeroTable> heroTableList = new();

    [Serializable]
    public class GmHeroTable
    {
        [TableColumnWidth(60, false)]
        [VerticalGroup("道具图标")]
        [PreviewField(Alignment = ObjectFieldAlignment.Center)]
        [HideLabel]
        public Texture Icon;

        [VerticalGroup("英魂ID"), LabelWidth(50)] [HideLabel]
        public int HeroId = 0;

        [VerticalGroup("英魂名称"), LabelWidth(50)] [HideLabel]
        public string HeroName = string.Empty;

        [TableColumnWidth(70, false)]
        [VerticalGroup("功能")]
        [Button("一键强化装备", ButtonSizes.Medium)]
        public void IntensifyEquip()
        {
            // GameFacade.Instance.StartCoroutine(SendCode());
        }

        // private IEnumerator SendCode()
        // {
        //     foreach (var itemId in mEquipIdList)
        //     {
        //         Dictionary<int, int> dicNeedItems = new Dictionary<int, int>();
        //         int maxLv = 0;
        //         int curLv = 0;
        //         GetIntensifyNeedItem(itemId, ref dicNeedItems,ref maxLv, curLv);
        //         foreach (var pair in dicNeedItems)
        //         {
        //             ProtoGmRequest req = new ProtoGmRequest();
        //             req.Param = $"additem:{pair.Key.ToString()}:{pair.Value.ToString()}";
        //             TCPSender.ProtoGmRequest(req);
        //             yield return new WaitForSeconds(0.05f);
        //         }
        //         while (curLv <= maxLv)
        //         {
        //             TCPSender.C2SHeroEquipIntensifyReq(itemId, HeroId);
        //             ++curLv;
        //             yield return new WaitForSeconds(0.05f);
        //         }
        //     }
        //     Tips.ShowImageTips("GM指令完成");
        // }

        // private List<int> mEquipIdList;

        // public GMHeroTable(CSVHeroInfo heroTable)
        // {
        //     Icon = AssetDatabase.LoadAssetAtPath<Texture>($"Assets/Project/Res/{heroTable.sAvatarPath}");
        //     HeroId = heroTable.iHeroID;
        //     HeroName = heroTable.sHeroName;
        //     mEquipIdList = new List<int>();
        //     mEquipIdList.Add(heroTable.iWeaponID);
        //     mEquipIdList.AddRange(heroTable.iListEquipID);
        // }
    }

    #endregion

    #region 其他功能

    [FoldoutGroup("其他功能")]
    [Button("快速断线", ButtonSizes.Medium)]
    public void QuickOutline()
    {
        // HeartBeatManager.Instance.Reset();
        // HeartBeatManager.Instance.Enable = false;
        // NetworkManager.Instance.OnConnectFail();
    }

    #endregion


    // //强化装备至满级
    // private void IntensifyItem(string itemIdStr)
    // {
    //     if (string.IsNullOrWhiteSpace(itemIdStr))
    //     {
    //         return;
    //     }
    //     int itemId = 0;
    //     if (!int.TryParse(itemIdStr, out itemId))
    //     {
    //         return;
    //     }
    //     var itemTable = CSVItemAll.Get(itemId);
    //     if (itemTable.iItemType != (int)EItemTypes.Equip && itemTable.iItemType != (int)EItemTypes.Weapon)
    //     {
    //         return;
    //     }
    //     var inventory = NetData.Instance.Find<NetInventory>();
    //     var datas = inventory.Find(InventoryBoxType.DeopEuipBag).GetItemListWithID(itemId);
    //     if (datas.Count <= 0)
    //     {
    //         return;
    //         // ProtoGmRequest req = new ProtoGmRequest();
    //         // req.Param = $"additem:{itemIdStr}";
    //         // TCPSender.ProtoGmRequest(req);
    //     }
    //     var itemData = datas[0];
    //     var curLv = itemData.IntensifyLv;

    //     Dictionary<int, int> dicNeedItems = new Dictionary<int, int>();
    //     int maxLv = 0;
    //     GetIntensifyNeedItem(itemId, ref dicNeedItems,ref maxLv, curLv);
    //     foreach (var pair in dicNeedItems)
    //     {
    //         ProtoGmRequest req = new ProtoGmRequest();
    //         req.Param = $"additem:{pair.Key.ToString()}:{pair.Value.ToString()}";
    //         TCPSender.ProtoGmRequest(req);
    //     }

    //     while (curLv <= maxLv)
    //     {
    //         TCPSender.C2SIntensifyEquipReq(itemData.ItemSrl);
    //         ++curLv;
    //     }
    // }
    // //获取装备升至满级所需材料
    // public static void GetIntensifyNeedItem(int itemId, ref Dictionary<int, int> dicNeedItems, ref int maxLv, int curLv = 0)
    // {
    //     if (null == dicNeedItems)
    //     {
    //         dicNeedItems = new Dictionary<int, int>();
    //     }
    //     var equipTable = CSVEnhanceEquip.Get(itemId);
    //     if (null == equipTable)
    //     {
    //         return;
    //     }
    //     var intensifyTables = CSVIntensify.GetIntensifys(equipTable.iIntensifyType);
    //     maxLv = intensifyTables.Count;
    //     if (curLv >= maxLv || maxLv == 0)
    //     {
    //         return;
    //     }
    //     dicNeedItems.Add(ItemId.GoldCoin, 0);
    //     foreach (var table in intensifyTables.Values)
    //     {
    //         if (table.iIntensifyLv < curLv)
    //         {
    //             continue;
    //         }
    //         for (int i = 0; i < table.iListStuffIDs.Count; ++i)
    //         {
    //             if (!dicNeedItems.ContainsKey(table.iListStuffIDs[i]))
    //             {
    //                 dicNeedItems.Add(table.iListStuffIDs[i], 0);
    //             }
    //             dicNeedItems[table.iListStuffIDs[i]] += table.iListStuffCounts[i];
    //         }
    //         dicNeedItems[ItemId.GoldCoin] += table.iGoldConsumption;
    //     }
    // }
    // //发送GM命令
    // private void SendGMCode(string code, string codeParam)
    // {
    //     if (code.Equals("monteruseskill"))
    //     {
    //         var monster_list = SceneUnitContainer.Instance.Get<MonsterComponent>(ESceneUnitType.Monster);
    //         if (null == monster_list || monster_list.Count <= 0)
    //         {
    //             return;
    //         }
    //         var monster = monster_list[0];
    //         var skillMgr = monster.GetComponent<SkillManager>();
    //         skillMgr.UseSkill(int.Parse(codeParam));
    //         return;
    //     }
    //     if (code == "hero")
    //     {
    //         CharacterSpawner.SpawnHero(int.Parse(codeParam));
    //         return;
    //     }
    //     if (code == "guide")
    //     {
    //         RookieGuideManager.Instance.StartGuide(int.Parse(codeParam));
    //         return;
    //     }
    //     if (code == "fingerspeed")
    //     {
    //         Messenger.Post(UIMessage.CameraLock.OnShowFingerSpeedStateChange);
    //         return;
    //     }
    //     if (code == "uaf")
    //     {
    //         Auf();
    //     }
    //     if (code.Contains("unlockfunc"))
    //     {
    //         var funId = 0;
    //         var strs = (code + ":" + codeParam).Split(':');
    //         if (strs.Length >= 2)
    //         {
    //             if (int.TryParse(strs[1], out funId))
    //             {
    //                 var funcConf = CSVFuncitonCollection.Get(funId);
    //                 var unlockType = funcConf.iOpenType;
    //                 switch (unlockType)
    //                 {
    //                     case 1:
    //                         break;
    //                     case 2:
    //                         var unlockTaskId = funcConf.iOpenparameter;
    //                         Tasked(unlockTaskId);
    //                         break;
    //                 }
    //             }
    //         }
    //         return;
    //     }
    //     if (code == "use")
    //     {
    //         if (int.TryParse(codeParam, out int skill_id))
    //         {
    //             var main_player = SceneUnitContainer.Instance.MainPlayer;
    //             var list = SceneUnitContainer.Instance.Get<MonsterComponent>(ESceneUnitType.Monster);
    //             foreach (var mon in list)
    //             {
    //                 if (mon.MonsterVO.IsBoss == false)
    //                 {
    //                     continue;
    //                 }
    //                 var skillManager = mon.GetComponent<SkillMgrAI>();
    //                 skillManager.UseAISkill(skill_id, main_player.transform.position);
    //             }
    //         }
    //         return;
    //     }
    //     ProtoGmRequest req = new ProtoGmRequest();
    //     req.Param = string.Format($"{code}:{codeParam}");
    //     TCPSender.ProtoGmRequest(req);
    // }
    // //角色页面功能全解锁
    // public async void Auf()
    // {
    //     var lst = CSVFuncitonCollection.GetAllLst();
    //     for (int i = 0; i < lst.Count; i++)
    //     {
    //         await TimerComponent.Instance.WaitForSeconds(0.2f);
    //         Tasked(lst[i].iOpenparameter);
    //     }
    // }
    // //完成任务
    // private void Tasked(int id)
    // {
    //     if (TaskTools.IsTaskDilivered(id))
    //     {
    //         return;
    //     }
    //     var conf = CSVQuest.Get(id);
    //     if (conf != null)
    //     {
    //         var lst = conf.iListUnLockTask;
    //         for (int i = 0; i < lst.Count; i++)
    //         {
    //             Tasked(lst[i]);
    //         }
    //         ProtoGmRequest req = new ProtoGmRequest();
    //         req.Param = string.Format($"tasked:{id}");
    //         TCPSender.ProtoGmRequest(req);
    //     }
    // }
}
